package com.shop2cn.app.liveseller.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.app.liveseller.parameter.SelectProductListBean;
import com.shop2cn.app.liveseller.service.SelectProductListCall;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.AuthCallServiceV2;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.utils.TestDataManager;
/**
*获取可添加直播商品列表
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SelectProductList{
	private static SelectProductListBean selectproductlistBean;
	private static SelectProductListCall selectproductlistCall;
	private static int sellerId ;
	private static String token ;
	private static int csId;
	private static String cstoken;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取可添加直播商品列表");
		try {
			sellerId = GodmchManageCallService.CreateSellerMch();
			token=AuthCallServiceV2.createToken(sellerId, "app");
			csId = GodmchManageCallService.bindClientService(
					sellerId, 1);
			cstoken = AuthCallServiceV2.createToken(csId, "app");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		selectproductlistBean=new SelectProductListBean();
		selectproductlistCall=new SelectProductListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(selectproductlistCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SelectProductList_001() {
		Logger.start(true,"获取可添加直播商品列表");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(sellerId, "autotest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Logger.comment("创建商品：" + pid);
			//等待商品同步
			Thread.sleep(1000);
			selectproductlistBean.setPageIndex(1);
			selectproductlistBean.setPageSize(10);
			selectproductlistBean.setRequestId(TestDataManager.getRandomUUID().toString());
			selectproductlistCall.setData(selectproductlistBean);
			selectproductlistCall.addHeader("ymt-pars", "accesstoken="+token);
			selectproductlistCall.callService();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SelectProductList_002() {
		Logger.start(true,"客服获取可添加直播商品列表");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(sellerId, "autotest",
					false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Logger.comment("创建商品：" + pid);
			//等待商品同步
			Thread.sleep(1000);
			selectproductlistBean.setPageIndex(1);
			selectproductlistBean.setPageSize(10);
			selectproductlistBean.setRequestId(TestDataManager.getRandomUUID().toString());
			selectproductlistCall.setData(selectproductlistBean);
			selectproductlistCall.addHeader("ymt-pars", "accesstoken="+cstoken);
			selectproductlistCall.callService();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}